<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="import" href="../header.html" id="page1">
		<!--标准mui.css-->
		<link rel="stylesheet" href="../../css/mui.min.css">
		<!--App自定义的css-->
		<!-- <link rel="stylesheet" type="text/css" href="../css/app.css" /> -->
		<link rel="stylesheet" type="text/css" href="../../css/app.css" />
		<link href="../../css/mui.picker.css" rel="stylesheet" />
		<link href="../../css/mui.poppicker.css" rel="stylesheet" />
		<style>
			h5 {
				margin: 5px 7px;
			}
		</style>
		<style>
			.mui-btn {
				font-size: 16px;
				padding: 8px;
				margin: 3px;
			}
			h5.mui-content-padded {
				margin-left: 3px;
				margin-top: 20px !important;
			}
			h5.mui-content-padded:first-child {
				margin-top: 12px !important;
			}
			.ui-alert {
				text-align: center;
				padding: 20px 10px;
				font-size: 16px;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">新建工单</h1>
		</header>
		<div class="mui-content" id="rrapp">
			<div class="mui-content-padded " style="margin: 5px;">
				<!-- <form class="mui-input-group"> -->
					<div class="mui-input-row mui-content-padded">
						<label>设备点</label>
						<!-- <input v-model="equipmentId" id="userResult" type="text" placeholder="设备点"> -->
						<input id='showUserPicker'  v-model="bussMaintainTask.equipmentName"  type="text" placeholder="设备点"  readonly="readonly"></input>
					   <!-- <div id='userResult' class="ui-alert"></div> -->
					</div>
					<div class="mui-input-row mui-content-padded">
					<label>指派给</label>
				<!-- 	<input type="text" placeholder="指派人"> -->
					<!-- <input id="userResult2" type="text" placeholder="设备点"> -->
					<input id='showUserPicker2' v-model="bussMaintainTask.handlerName" class="" type="text" placeholder="指派人" readonly="readonly"></input>
					</div>
					<div class="mui-input-row mui-content-padded">
						<label>紧急度</label>
					<!-- 	<input type="text" class="mui-input-clear" placeholder="等级"> -->
					<!-- <input id="userResult3" type="text" placeholder="设备点"> -->
					<input id='showUserPicker3'  v-model="bussMaintainTask.gradeNumName" class="" type="text" placeholder="紧急度" readonly="readonly"></input>
					</div>
					<div class="mui-input-row mui-content-padded">
						<label>工单类型</label>
					<!-- 	<input type="text" class="mui-input-clear" placeholder="等级"> -->
					<!-- <input id="userResult3" type="text" placeholder="设备点"> -->
					<input id='showUserPicker4' v-model="bussMaintainTask.typeDesc"  class="" type="text" placeholder="工单类型" readonly="readonly"></input>
					</div>
					<div class="mui-input-row" style="margin: 10px 5px;">
						<label>状况描述</label>
						<textarea v-model="bussMaintainTask.content"  id="textarea" rows="5" placeholder="状况描述"></textarea>
					</div>
					
					<div class="mui-button-row">
						<button type="button" class="mui-btn mui-btn-primary" @click="save">确认</button>&nbsp;&nbsp;
						<button type="button" class="mui-btn mui-btn-danger" @click="fh">返回</button>
					</div>
				<!-- </form> -->
				
				
				
			</div>
		</div>
		<!--<script src="../js/mui.picker.min.js"></script>-->
		<script src="../../js/mui.picker.js"></script>
		<script src="../../js/mui.poppicker.js"></script>
		<script src="../../js/city.data.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/city.data-3.js" type="text/javascript" charset="utf-8"></script>
		<script>
			(function($, doc) {
				$.init();
					
				
				$.ready(function() {
					
				});
			})(mui, document);
			
			
			var vm = new Vue({
				el:'#rrapp',
				data:{
					showList: true,
					title: null,
					insIndetailsugtion: {},
					 bussMaintainTask: {
					   id: 0,
					   handler: '',
					   equipmentId: '',
					   resultStatus: 0,
					   type: 0,
					   content: '',
					   gradeNum: '',
					   status: 0,
					 
					   resultContent: '',
					   resultFileIds: '',
					   sourceType: '',
					   resultFileIdsArr:[]
					 	
					 },
				},
				methods: {
					getm: function () {
						mui.ajax(baseUrl+'/buss/bussrtuequipment/list',{
							data:{
								//'token':'7404549df0903eee9618ca83e9940e76',
								'page': 1,
								'limit': 999,
							},
							dataType:'json',//服务器返回json格式数据
							async: false,
							type:'get',//HTTP请求类型
							//headers:{'Content-Type':'application/json'},	              
							success:function(data){
								console.log(data)
								var gdata = [];
								for (var i = 0; i < data.page.list.length; i++) {
									var getlist = data.page.list[i];
									/**
									 * 获取对象属性的值
									 * 主要用于过滤三级联动中，可能出现的最低级的数据不存在的情况，实际开发中需要注意这一点；
									 * @param {Object} obj 对象
									 * @param {String} param 属性名
									 */
									var b1 = getlist.id;
									var b2 = getlist.name;
									var gb = {"value":b1,"text":b2};
									gdata.push(gb);
									var _getParam = function(obj, param) {
										return obj[param] || '';
									};
									//普通示例
									var userPicker = new mui.PopPicker();
									
									userPicker.setData(
										gdata
									);
									var showUserPickerButton = document.getElementById('showUserPicker');
									var userResult = document.getElementById('showUserPicker');
									showUserPickerButton.addEventListener('click', function(event) {
										if(vm.bussMaintainTask.equipmentId!=''&&vm.bussMaintainTask.equipmentId!=null){
											userPicker.pickers[0].setSelectedValue(vm.bussMaintainTask.equipmentId)
										}
										userPicker.show(function(items) {
											userResult.value = items[0].text 
											vm.bussMaintainTask.equipmentId = items[0].value
										});
									}, false);
								}
							}
						});
						//222
						mui.ajax(baseUrl+'/sys/user/list2',{
							data:{
								'page': 1,
								'limit': 999,
							},
							dataType:'json',//服务器返回json格式数据
							async: false,
							type:'get',//HTTP请求类型
							//headers:{'Content-Type':'application/json'},	              
							success:function(data){
								var gdata = [];
								for (var i = 0; i < data.page.list.length; i++) {
									var getlist = data.page.list[i];
									/**
									 * 获取对象属性的值
									 * 主要用于过滤三级联动中，可能出现的最低级的数据不存在的情况，实际开发中需要注意这一点；
									 * @param {Object} obj 对象
									 * @param {String} param 属性名
									 */
									var b1 = getlist.id;
									var b2 = getlist.name;
									var gb = {"value":b1,"text":b2};
									gdata.push(gb);
									var _getParam = function(obj, param) {
										return obj[param] || '';
									};
									//普通示例
									var userPicker = new mui.PopPicker();
									
									
									userPicker.setData(
									gdata
									);
									var showUserPickerButton = document.getElementById('showUserPicker2');
									var userResult = document.getElementById('showUserPicker2');
									showUserPickerButton.addEventListener('tap', function(event) {
										if(vm.bussMaintainTask.handler!=''&&vm.bussMaintainTask.handler!=null){
											userPicker.pickers[0].setSelectedValue(vm.bussMaintainTask.handler)
										}
										userPicker.show(function(items) {
											userResult.value = items[0].text 
											vm.bussMaintainTask.handler = items[0].value
										});
									}, false);
								}
							}
						});
						//333
						mui.ajax(baseUrl+'/sys/dict/select',{
							data:{
								"type": "alarm_level_00"
							},
							dataType:'json',//服务器返回json格式数据
							async: false,
							type:'get',//HTTP请求类型
							//headers:{'Content-Type':'application/json'},	              
							success:function(data){
								var gdata = [];
								if(data.list!=null){
								for (var i = 0; i < data.list.length; i++) {
									var getlist = data.list[i];
									/**
									 * 获取对象属性的值
									 * 主要用于过滤三级联动中，可能出现的最低级的数据不存在的情况，实际开发中需要注意这一点；
									 * @param {Object} obj 对象
									 * @param {String} param 属性名
									 */
									var b1 = getlist.id;
									var b2 = getlist.name;
									var gb = {"value":b1,"text":b2};
									gdata.push(gb);
									var _getParam = function(obj, param) {
										return obj[param] || '';
									};
									//普通示例
									var userPicker = new mui.PopPicker();
									
									
									userPicker.setData(
									gdata
									);
									var showUserPickerButton = document.getElementById('showUserPicker3');
									var userResult = document.getElementById('showUserPicker3');
									showUserPickerButton.addEventListener('tap', function(event) {
										if(vm.bussMaintainTask.gradeNum!=''&&vm.bussMaintainTask.gradeNum!=null){
											userPicker.pickers[0].setSelectedValue(vm.bussMaintainTask.gradeNum)
										}
										userPicker.show(function(items) {
											userResult.value = items[0].text 
											vm.bussMaintainTask.gradeNum = items[0].value
										});
									}, false);
								}
									}
							}
						});
						///44444444444444444444444444444
						/**
						 * 获取对象属性的值
						 * 主要用于过滤三级联动中，可能出现的最低级的数据不存在的情况，实际开发中需要注意这一点；
						 * @param {Object} obj 对象
						 * @param {String} param 属性名
						 */
						var _getParam = function(obj, param) {
							return obj[param] || '';
						};
						//普通示例
						var userPicker = new mui.PopPicker();
						
						
						userPicker.setData([
						{value:"0",text:"运维工单"},
						{value:"1",text:"维修工单"}
						]);
						var showUserPickerButton = document.getElementById('showUserPicker4');
						var userResult = document.getElementById('showUserPicker4');
						showUserPickerButton.addEventListener('tap', function(event) {
							if(vm.bussMaintainTask.type!=''&&vm.bussMaintainTask.type!=null){
								userPicker.pickers[0].setSelectedValue(vm.bussMaintainTask.type)
							}
							userPicker.show(function(items) {
								userResult.value = items[0].text 
								vm.bussMaintainTask.type = items[0].value
							});
						}, false);
						console.log(T.p("gid"))
						var id = T.p("gid");
						if(id!=null&&id!=null){
							 mui.get(baseUrl+"/buss/bussmaintaintask/info/"+id,function(data,status){
								console.log(data.bussMaintainTask)
								vm.bussMaintainTask = data.bussMaintainTask
								
								
							});
						}
					},
					save : function(){
						var url = vm.bussMaintainTask.id == null ? "/buss/bussmaintaintask/save" : "/buss/bussmaintaintask/update";
						mui.ajax(baseUrl+url,{
							//data:{
							data:JSON.stringify(vm.bussMaintainTask),
							//},
							//dataType:'json',//服务器返回json格式数据
							async: false,
							contentType: "application/json",
							type:'post',//HTTP请求类型
							//headers:{'Content-Type':'application/json'},	              
							success:function(data){
								if(data.code == 0){
									mui.toast('添加成功', {
										duration: 'long',
										type: 'div'
									})
								}else{
									mui.toast('添加失败', {
										duration: 'long',
										type: 'div'
									})
								}
								
							},error: function(xhr, type, errorThrown) {
								//异常处理；
								mui.toast('添加失败', {
									duration: 'long',
									type: 'div'
								})
							}
					})
					},
					fh:function(){
					   console.log('返回')
					   mui.back()		
/* 					   mui.openWindow({
						url: "A页面",
						createNew:true
						});
 */					}
				},
				mounted:function(){
					this.getm();
				}
			});
			

		</script>
	</body>

</html>